package com.xinke.juc.case03;

import lombok.extern.slf4j.Slf4j;

/**
 * @Author：xinke
 * @Date：2025/9/30
 * @Desc: 线程优先级
 */
@Slf4j
public class TestPriority {
    public static void main(String[] args) {
        Runnable r1 = ()->{
            int count = 0;
            for(;;){
                log.info("--------->R1\t"+count++);
            }
        };
        Runnable r2 = ()->{
            int count = 0;
            for(;;){
//                Thread.yield();
                log.info("--------->R2\t"+count++);
            }
        };
        Thread t1 = new Thread(r1,"t1");
        Thread t2 = new Thread(r2,"t2");
        t1.setPriority(Thread.MIN_PRIORITY);
        t2.setPriority(Thread.MAX_PRIORITY);
        t1.start();
        t2.start();
    }
}
